package com.mz.ozy.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.mz.ozy.R;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2018/11/22.
 */

public class HotSearchTagAdapter extends BaseAdapter {
    private Context mContext;
    private List<String> mDataList;

    public HotSearchTagAdapter(Context context, List<String> mDataList) {
        this.mContext = context;
        this.mDataList = mDataList;

    }

    @Override
    public int getCount() {
        return mDataList.size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_tag, null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        String s = mDataList.get(position);
        viewHolder.mTagTv.setText(s);

//        View view = LayoutInflater.from(mContext).inflate(R.layout.item_tag, null);
//        TextView tagTv = view.findViewById(R.id.tagTv);
//        String t = mDataList.get(position);
//        tagTv.setText(t);

        return convertView;
    }



    class ViewHolder {
        @BindView(R.id.tagTv)
        TextView mTagTv;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
